package com.ruoyi.web.controller.bussiness;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.entity.po.TPlayerIntroduce;
import com.ruoyi.service.TPlayerIntroduceService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/playerIntroduce")
@Api(tags = "PC-5.选手介绍管理")
public class PlayerIntroduceController extends BaseController {

    @Autowired
    private TPlayerIntroduceService playerIntroduceService;

    @GetMapping("/list")
    @ApiOperation("选手介绍列表")
    public TableDataInfo list(TPlayerIntroduce playerIntroduce) {
        startPage();
        List<TPlayerIntroduce> list = playerIntroduceService.selectPlayerIntroduceList(playerIntroduce);
        return getDataTable(list);
    }

    @PostMapping("/add")
    @ApiOperation("新增选手介绍")
    public AjaxResult add(@RequestBody TPlayerIntroduce playerIntroduce) {
        if (playerIntroduceService.selectByPlayerId(playerIntroduce.getPlayerId()) != null) {
            return error("选手介绍已存在");
        }
        return toAjax(playerIntroduceService.insertSelective(playerIntroduce));
    }

    @PostMapping("/delete")
    @ApiOperation("删除选手介绍")
    public AjaxResult delete(@RequestBody Integer[] ids) {
        return toAjax(playerIntroduceService.deleteByPrimaryKeys(ids));
    }

    @PostMapping("/edit")
    @ApiOperation("修改选手介绍")
    public AjaxResult edit(@RequestBody TPlayerIntroduce playerIntroduce) {
        return toAjax(playerIntroduceService.updateByPrimaryKeySelective(playerIntroduce));
    }
}
